# -*- coding: utf-8 -*-
######################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 OpenERP s.a. (<http://openerp.com>).
# Copyright (C) 2013 INIT Tech Co., Ltd (http://init.vn).
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
######################################################################

from osv import fields,osv
from tools.translate import _
import pooler
import netsvc
from email.Utils import COMMASPACE
import time
from datetime import date,datetime,timedelta

class mail_group(osv.osv):
    _inherit = "mail.group"
    
    _columns = {
        'user_id': fields.many2one('res.users', 'User'),
    }    
    
mail_group()



class mail_group_member(osv.osv):
    _inherit = "mail.group.member"
    
    _columns = {
        'user_id': fields.many2one('res.users', 'User'),
        'company_id': fields.many2one('res.company', 'Company'),
    }    
    
    _defaults = {
        'not_interested': lambda *a: True,
    }
    
    def onchange_user_id(self, cr, uid, ids, user_id):
        v = {}
        res_user = self.pool.get('res.users')
        if user_id:
            user = res_user.browse(cr, uid, user_id)
            v['email'] = user.user_email
            v['company_id'] = user.company_id.id
        return {'value': v}    
mail_group_member()
